package com.wobito.common.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @Author Wangbaba
 * @Date 2024/8/14 13:42
 * @Version 1.0
 */
public class EncrypUtils {

    private static final BCryptPasswordEncoder passwordEncoder=new BCryptPasswordEncoder();

    /**
     * 密码加密
     */
    public static String getEncryPassword(String pwd){
        return "{bcrypt}"+passwordEncoder.encode(pwd);
    }

    /**
     * 比对密码
     */
    public static boolean matches(String rawPassword,String encodedPassword){
        return passwordEncoder.matches(rawPassword,encodedPassword);
    }
}
